import request from '@/config/axios'

// 存货管理 VO
export interface StockVO {
  id: number // id
  inventoryId: string // 存货id
  qty: number // 数量
  inventoryCode: any // 
  inventoryName: any // 
  inventorySpecModel:any
  inventoryBrand:any
  inventoryIsBatch:any
  inventoryUnitName:any
  useQty:any
  irate:any
  price:any
  itaxprice:any
  orderId:any
  locationName:any
  batchCode:any
}

// 存货管理子 VO
export interface StockLogVO {
  id: number // id
  inventoryCode: any // 
  inventoryName: any // 
  inventorySpecModel:any
  inventoryId:any
  inventoryBrand:any
  inventoryIsBatch:any
  inventoryUnitName:any
  qty:any
  useQty:any
  irate:any
  price:any
  itaxprice:any
  orderId:any
  locationName:any
  batchCode:any

}

// 存货管理 API
export const StockApi = {
  // 查询存货管理分页
  getStockPage: async (params: any) => {
    return await request.get({ url: `/wms/stock/page`, params })
  },

  // 查询存货管理详情
  getStock: async (id: number) => {
    return await request.get({ url: `/wms/stock/get?id=` + id })
  },

  // 新增存货管理
  createStock: async (data: StockVO) => {
    return await request.post({ url: `/wms/stock/create`, data })
  },

  // 修改存货管理
  updateStock: async (data: StockVO) => {
    return await request.put({ url: `/wms/stock/update`, data })
  },

  // 删除存货管理
  deleteStock: async (id: number) => {
    return await request.delete({ url: `/wms/stock/delete?id=` + id })
  },

  // 导出存货管理 Excel
  exportStock: async (params) => {
    return await request.download({ url: `/wms/stock/export-excel`, params })
  },

// ==================== 子表（存货管理子） ====================

  // 获得存货管理子列表
  getStockLogListByInventoryId: async (params) => {
    return await request.get({ url: `/wms/stock/stock-log/list-by-inventory-id` , params })
  },

  getStockLogUseAll: async () => {
    return await request.get({ url: `/wms/stock/stock-log/findUsedAll`})
  },

  // 查询存货管理子表详情
  getStockLog: async (id: number) => {
    return await request.get({ url: `/wms/stock/getStockLog?id=` + id })
  },

    // 获取销售订单相关的存货
    findAboutSaleStockLog: async (params) => {
      return await request.get({ url: `/wms/stock/findAboutSaleStockLog`,params})
    },
  
    //各种条件查询有库存的存货
    findUseListByParam: async (params) => {
      return await request.get({ url: `/wms/stock/findUseListByParam`,params})
    },
  
      //视图查询
      viewStock: async (params) => {
        return await request.get({ url: `/wms/stock/viewStock`,params})
      },
}
